﻿@using Inovout.Descriptor
@model IEnumerable<KuaJing.Customs.Domain.Declaration>

<div class="iui-panel">
    <h1>报关单查询</h1>
    <div class="row form-inline">
        @using (Html.BeginForm())
        {
            <div class="col-md-10">
                @Html.Query()
            </div>
            <div class="col-md-2">
                @Html.Submit("查询", new { @class = "btn btn-default btn-primary" })
            </div>
        }
    </div>
</div>
<div class="iui-panel iui-panel-table">
    <h1>
        报关单列表
        <span class="ico-add">
            @Html.ActionLink("同步Svn报关单", "SyncSvn", new { ReturnUrl = Request.Url })
            @Html.ActionLink("上传Pdf报关单", "Upload", new { ReturnUrl = Request.Url })
        </span>
    </h1>
    <div>
        @Html.Table(() => "没有员工数据" + Html.ActionLink("新增", "Edit", new { ReturnUrl = Request.Url })).Build(properties =>
   {
       properties.Extend("报关单号").RenderAs(m => Html.ActionLink(m.Code, "Download", "File", new { id = m.File.Id }, new { target = "_blank" }));
       properties.Add(m => m.ContractNumber);
       //properties.Add(m => m.ExportDate);
       properties.Add(m => m.DestinationlCountry);
       //properties.Extend("报关币种").RenderAs(m => m.Items.First().CurrencyName);
       properties.Extend("报关金额").RenderAs(m => m.Items.Sum(i => i.GoodsAmount));
       properties.Extend("操作", v => Html.ActionLink("编辑", "Edit", new { Id = v.Id, ReturnUrl = Request.Url }),
           v =>
           {
               KuaJing.Orders.Service.OrderService orderService = ViewBag.OrderService as KuaJing.Orders.Service.OrderService;
               KuaJing.Orders.Domain.Order order;
               if (orderService.TryGet(v, out order))
               {
                   return Html.ActionLink("查看订单", "Edit", "Order", new { Id = order.Id, ReturnUrl = Request.Url }, null);
               }
               else
               {
                   return Html.ActionLink("生成订单", "Generate", "Order", new { Id = v.Id, ReturnUrl = Request.Url }, null);

               }
           });
   })
    </div>
</div>
